package com.han.factory.before;

/**
 * @ClassName CoffeeStore
 * @Description 描述该类的功能
 * @Author duoduo Han
 * @Date 2024/6/4 10:14
 */
public class CoffeeStore {
    public Coffee orderCoffee(String type) {
        //声明Coffee类型的变量，根据不同类型创建不同的coff子类对象
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("对不起，您所点的咖啡没有。");
        }
        //加配料
        coffee.addMilk();
        coffee.addSugar();

        return coffee;
    }
}
